package com.xinminda.dcf;

import com.alibaba.fastjson.JSON;
import com.xinminda.dcf.api.ApiServiceTest;
import com.xinminda.dcf.app.UrlValue;
import com.xinminda.dcf.bean.TestLoginHeader;
import com.xinminda.dcf.bean.TestNewsListParams;
import com.xinminda.dcf.utils.fastjson.FastJsonConverterFactory;
import org.junit.Test;
import retrofit2.Response;
import retrofit2.Retrofit;


public class getNewsList {
    @Test
    public void test(){
        ApiServiceTest apiServiceTest = new Retrofit.Builder()
                .baseUrl(UrlValue.URL)
                .addConverterFactory(FastJsonConverterFactory.create())
                .build().create(ApiServiceTest.class);
        try {
           /* header:
            {
                "clientVersion": "2.0",
                    "deviceId": "1234567890",
                    "from": "ios",
                    "method": "news.newList",
                    "token": "0d422146417144eb844e1e429f5b55ec",
                    "userId": 0
            }

          */

            TestLoginHeader loginHeader = new TestLoginHeader();
            loginHeader.setVersion("2.0");
            loginHeader.setDeviceId("1234567890");
            loginHeader.setFrom("ios");
            loginHeader.setMethod("news.newList");
            loginHeader.setToken("6ac2f9d863704560be07f350ae4bfe90");
            loginHeader.setUserId(1);
            String header = JSON.toJSONString(loginHeader);
            System.out.println(header);
            TestNewsListParams newsListParams = new TestNewsListParams();
            newsListParams.setColumnId(273);
            newsListParams.setPage(1);
            newsListParams.setRows(10);
            String params = JSON.toJSONString(newsListParams);
            System.out.println(params);
            Response<String> response = apiServiceTest.getNewsList(header, params).execute();
            String str = response.body();
            System.out.print(str);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
